package com.sg.business.model.dataset.organization;

import com.sg.business.model.IModelConstants;
import com.sg.business.model.Organization;
import com.sg.business.model.OrganizationProjectProvider;
import com.sg.widgets.commons.dataset.MasterDetailDataSetFactory;

public class OrgOfSelector extends MasterDetailDataSetFactory {

	public OrgOfSelector() {
		super(IModelConstants.DB, IModelConstants.C_ORGANIZATION);
	}

	@Override
	protected String getDetailCollectionKey() {
		return Organization.F__ID;
	}

	@Override
	protected Object getMasterValue() {
		if (master instanceof OrganizationProjectProvider) {
			OrganizationProjectProvider organizationProjectProvider = (OrganizationProjectProvider) master;
			Organization organization = organizationProjectProvider
					.getOrganization();
			return organization.get_id();
		}

		return super.getMasterValue();
	}
}
